<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<% request.getSession().removeAttribute("loginUser"); %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login Page</title>
<style type="text/css">
	.error {
		color: red;
	}
</style>
<script type="text/javascript" src="scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
	function doSubmit() {
		if(validate()) {
			$("#form").submit();
		}
	}
	
	function validate() {
		var username = $("#username").val();
		if(username.length < 6 || username.length > 20) {
			$("#username_error").html("Username invalid !");
			return false;
		}
		var password = $("#password").val();
		if(password.length < 6 || password.length > 20) {
			$("#password_error").html("Password invalid !");
			return false;
		}
		return true;
	}
	
	function hiddenErrorMsg(id) {
		$("#" + id + "_error").html('');
	}
</script>
</head>
<body>
<h1>Login Page !</h1><hr />
<form action="UserServlet" method="post" id="form">
<input id="username" name="username" onclick="javascript:hiddenErrorMsg(this.id);" /><label id="username_error" class="error"></label><br />
<input type="password" id="password" onclick="javascript:hiddenErrorMsg(this.id);" name="password" /><label id="password_error" class="error"></label><br />
<input type="hidden" name="method" value="login" />
<input type="button" value="LOGIN" onclick="javascript:doSubmit();" />
</form>
</body>
</html>